# Maintainer: Balló György <ballogyor+arch at gmail dot com>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Geoffroy Carrier <geoffroy.carrier@koon.fr>

pkgbase=lxrandr
pkgname=(lxrandr lxrandr-gtk3)
pkgver=0.3.2
pkgrel=3
pkgdesc="Monitor configuration tool (part of LXDE)"
arch=('loong64' 'x86_64')
license=('GPL2')
url="https://lxde.org/"
depends=('gtk2' 'gtk3' 'xorg-xrandr')
makedepends=('intltool')
source=("https://downloads.sourceforge.net/lxde/$pkgbase-$pkgver.tar.xz")
md5sums=('5101ab29d87fb2b56a5ec5bc8bc3f258')
sha256sums=('8b5edfc9718061bc161fe51d388697cbaa819d6f8013ed24ba22f438e0dbc312')

build() {
  # GTK+ 2 version
  [ -d gtk2 ] || cp -r $pkgbase-$pkgver gtk2
  cd gtk2
  ./configure --sysconfdir=/etc --prefix=/usr
  make

  cd "$srcdir"
  # GTK+ 3 version
  [ -d gtk3 ] || cp -r $pkgbase-$pkgver gtk3
  cd gtk3
  ./configure --sysconfdir=/etc --prefix=/usr --enable-gtk3
  make
}

package_lxrandr() {
  groups=('lxde')
  depends=('gtk2' 'xorg-xrandr')

  cd gtk2
  make DESTDIR="$pkgdir" install
}

package_lxrandr-gtk3() {
  groups=('lxde-gtk3')
  pkgdesc+=' (GTK+ 3 version)'
  depends=('gtk3' 'xorg-xrandr')
  conflicts=('lxrandr')

  cd gtk3
  make DESTDIR="$pkgdir" install

  # Ignore package by AppStream to avoid duplicated IDs
  echo 'X-AppStream-Ignore=true' >> "$pkgdir/usr/share/applications/$pkgbase.desktop"
}
